package org.ztuffaha.amqsecurity;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.File;

import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.jaas.GroupPrincipal;
import org.apache.activemq.security.AuthenticationUser;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * A simple authentication plugin
 *
 * @author ztuffaha
 * @version $Revision: 564679 $
 * @org.apache.xbean.XBean element="simpleAuthenticationPlugin"
 * description="Provides a simple authentication plugin
 * configured with a map of user-passwords and a map of
 * user-groups or a list of authentication users"
 */
public class ZSecurityPlugin implements BrokerPlugin
{
    private static final Log LOG = LogFactory.getLog(ZSecurityPlugin.class);

    private String filepath;
    private String scanTimeInSeconds;

    public String getFilepath()
    {
        return this.filepath;
    }

    public void setFilepath(String filepath)
    {
        this.filepath = filepath;
        LOG.info(filepath);
    }

    public String getScanTimeInSeconds()
    {
        return this.scanTimeInSeconds;
    }

    public void setScanTimeInSeconds(String scanTimeInSeconds)
    {
        this.scanTimeInSeconds = scanTimeInSeconds;
    }

    public ZSecurityPlugin()
    {
        reload();
    }

    public Broker installPlugin(Broker broker)
    {
        return new ZSecurityBroker(broker, filepath, Integer.valueOf(scanTimeInSeconds).intValue());
    }

    public void reload()
    {
        LOG.info("ZSecurity Plugin Loaded");
    }

}
